<template>
    <view class="content">
        <sl-filter :themeColor="themeColor" :menuList="menuList" @result="result"></sl-filter>
				
		<navigator v-for="(item,index) in houseall"   :url="'../me/content/houseDetail?house_id='+item.id"  hover-class="navigator-hover">		
		<view class="visitprint" >
				<image v-if="item.image" class="left" :src="siteUrl+item.image"></image>
				<image v-else class="left" :src="siteUrl+item.images.split(',',1)"></image>
				
				<view class="right">
					<view class="title">
						{{item.title}}
					</view>
					<view class="location">
						<image src="/static/img/icon-location.png"></image>
						<view class="note">{{item.location_near}}</view>
					</view>
					<view class="price">
						<font style="font-size:40rpx;color:#FF635C">{{item.price}}</font>元/月
					</view>				
				</view>		
		</view>
		</navigator>
		
		
	</view>
	
		
</template>

<script>
	var _self;
    import slFilter from '@/components/sl-filter/sl-filter.vue';
    export default {
        components: {
            slFilter
        },
        data() {
            return {
				siteUrl:this.websiteUrl,
				houseall:[],
                themeColor: '#000000',
                filterResult: '',
                menuList: [{
                        'title': '区域',
                        'detailTitle': '请选择区域',
                        'isMutiple': false,
                        'key': 'area_id',
                        'detailList': []

                    },
                    {
                        'title': '价格',
                        'key': 'price',
                        'isMutiple': false,
                        'detailTitle': '请选择价格范围',
                        'detailList': [{
                                'title': '价格',
                                'value': ''
                            },
                            {
                                'title': '1000~2000',
                                'value': '1'
                            },
                            {
                                'title': '2000~3000',
                                'value': '2'
                            },
                            {
                                'title': '3000~4000',
                                'value': '3'
                            },
                            {
                                'title': '10000以上',
                                'value': '4'
                            }
                        ]

                    },
                    {
                        'title': '户型',
                        'key': 'single',
                        'isMutiple': false,
                        'detailTitle': '请选择户型',
                        'detailList':[],
                    },
                    {
                        'title': '排序',
                        'key': 'sort',
                        'isSort': true,
                        'detailList': [{
                                'title': '筛选',
                                'value': ''
                            },
                            {
                                'title': '发布时间',
                                'value': 'addtime'
                            },
                            {
                                'title': '从低到高',
                                'value': 'low'
                            },
                            {
                                'title': '从高到低',
                                'value': 'high'
                            }
                        ]
                    }
                ]
            }
        },
        onLoad(e) {
		   _self= this
		  // console.log(e)
		   this.changeMenuListDetailList();
		   this.gethouseall(e.user_id); 
		   
			
        },
	
        methods: {
            result(val) {
               console.log('filter_result:' + JSON.stringify(val));
                this.filterResult = JSON.stringify(val, null, 2)
				//console.log(val.single);
				uni.request({
						url: this.websiteUrl+'/api.php/house/herHouse',
						method: 'POST',
						header: {
							'content-type':'application/x-www-form-urlencoded'						
						},
						data: {
							//token:uni.getStorageSync('token'),							
							layout:val.single,
							area_id:val.area_id,
							price: val.price,
							sort:val.sort														
						},
						success: function(res){							
							 //console.log(_self.houseall)
							_self.houseall = res.data.data
							console.log(_self.houseall)
						},
						
				});
            },			
			changeMenuListDetailList() {
				uni.request({
					url: this.websiteUrl+'/api.php/house/layout',
					method: 'GET',	
					header: {
						'content-type':'application/x-www-form-urlencoded'						
					},				
					success: function(res){	
						
						let tempDetailList_layout = res.data.data.layout
						
						let tempDetailList_area = res.data.data.area						
						_self.menuList[0].detailList = tempDetailList_area
						_self.menuList[0].detailList.unshift({
						        'title': '区域',
						        'value': ''
						    })
							
						_self.menuList[2].detailList = tempDetailList_layout
						_self.menuList[2].detailList.unshift({
						        'title': '户型',
						        'value': ''
						    })															
					},				
				});						
			},
			gethouseall($user_id){
				uni.request({
					url: this.websiteUrl+'/api.php/house/herHouse',
					method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded'						
					},
					data: {
						//token:uni.getStorageSync('token')
						user_id:$user_id
					},
					success: function(res){
						
						 //console.log(res)
						_self.houseall = res.data.data
						
					},
					
				});
			}
        }
    }
</script>
<style>
    .center {	
		display: flex;
		flex-direction: column;
		align-items: center;
		width:100%;
	}
	
	.visitprint{
		width:100%;
		height: 264rpx;
	}
	
	.visitprint .left{
		padding-left:32rpx;
		width:240rpx;
		height: 200rpx;
		padding-top:32rpx;
		float:left;
	}
	
	.visitprint .right{
		width:422rpx;
		height: 200rpx;
		margin-left:24rpx;
		float:left;
	}
	
	.right .title{
		font-size:30rpx;
		line-height: 42rpx;
		color:#373737;
		padding-top:32rpx;
	}
	
	.right .location{
		width:100%;
		height: 34rpx;
		margin-top:12rpx;
	}
	
	.right .location image{
		width:28rpx;
		height: 28rpx;
		float:left;
	}
	
	.right .location .note{
		float:left;
		font-size:24rpx;
		line-height: 34rpx;
		color:#999999;
		margin-left:12rpx;
	}
	
	
	.right .price{
		font-size:32rpx;
		line-height:48rpx;
		margin-top:12rpx;		
	}

</style>
